<template>
  <div class="addressed">
    <!-- 头部标题 -->
      <div class="header">
        <div>
          <a href="javascript:history.go(-1)"
            ><img id="back" src="img/返回.png" alt=""
          /></a>
        </div>
        <span>我的收获地址</span>
        <router-link to="/addressAdd">添加新地址</router-link>
      </div>
      <!--  -->
      <div class="main">
      <!-- 地址 -->
    <div class="address" v-for="(val, index) in array" :key="index">
      <div class="address_img">
        <img src="../../public/img/my8.png" alt="" />
      </div>
      <div class="address_middle">
        <div class="address_middle_a">
          <span>{{val.username}}</span>
          <span>{{val.phone}}</span>
        </div>
        <div class="address_middle_b">
          <span>{{val.address}}&nbsp;&nbsp;{{val.detaileAddress}}</span>
        </div>
      </div>
      <div class="address_right">
          <span @click="edit(index)">编辑</span>
        </div>
    </div>
    </div>
  </div>
</template>
<style  scoped>
.main{
  margin-top: 50px;
}
/* 头部登录标题 */
.addressed{
  width: 100%;
  background: #f6f6f6;
}
.header {
  position:fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 1.173333rem;
  line-height: 1.173333rem;
  display: flex;
  justify-content: space-around;
  background-color: white;
}
.header span {
  width: 60%;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
}

.header div{
  width: 20%;
}
.header div img {
  width: 0.533333rem;
}
.header a {
  width: 20%;
  font-size: 0.373333rem;
  color: #aaa;
}
/* 地址 */
.address {
  width: 95%;
  min-height: 100px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-left: 2%;
  padding: 10px 5px;
  border-radius: 4%;
  margin-top: 10px;
  background: #fff;
}
.address_img {
  width: 20%;
  padding: 5px;
}
.address_img img {
  zoom: 0.5;
}
.address_middle {
  width: 70%;
}
.address_middle div {
  margin-bottom: 5px;
}
.address_middle div:nth-child(1) span:nth-child(1) {
  font-size: 14px;
}
.address_middle_b span:nth-child(1){
  font-size: 12px;
  font-weight: 600;
}

.address_right{
  width: 10%;
  margin-left: 16px;
  font-size: 12px;
  color: #aaa;
}
.address_right span{
  padding: 2px;
  border-left: 1px solid #aaa;
}
</style>
<script>
export default {
  name: "addressed",
  data() {
    return {
      array:[]
    };
  },
  components: {},
  methods: {
    edit(index){
      var obj1=this.array[index]
      //console.log(obj1)
      this.$store.commit("edit",obj1)
      this.$router.replace({ path: "/addressedit" }); //进入地址编辑页面
    }

  },
  mounted: function () {
    this.array=JSON.parse(localStorage.getItem("address"));
  },
};
</script>